package com.lagou.mr.homework;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.CombineTextInputFormat;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;
public class Driver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        final Configuration conf = new Configuration();
        final Job job = Job.getInstance(conf, "HomeworkDriver");
        //设置jar包本地路径
        job.setJarByClass(Driver.class);
        //使用Mapper类和Reducer类
        job.setMapperClass(NumMapper.class);
        job.setReducerClass(NumReducer.class);
        //map的kv输出类型
        job.setMapOutputKeyClass(NumBean.class);
        job.setMapOutputValueClass(NullWritable.class);
        //设置reduce的输出
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(NumBean.class);

        //读取的数据路径
        FileInputFormat.setInputPaths(job,new Path("E:\\studyForBIgData\\第一阶段\\input"));
        FileOutputFormat.setOutputPath(job,new Path("E:\\studyForBIgData\\第一阶段\\output"));

        //提交任务
        final boolean flag = job.waitForCompletion(true);
        System.exit(flag ? 0 : 1);
    }
}